<?php
//获取文件列表
require "../config.php";
require "./user_authentication.php";
$user_name = $_POST['id']; //用户名
$Token = $_POST['Token']; //用户token
$userTime = $_POST['userTime']; //用户时间
$status_json = json_decode(user_authentication($user_name,$Token,$userTime),true); //用户登录验证
if($status_json['status']=="200"){
    $conn = mysqli_connect($MySqlHost, $MySqlUser, $MySqlPwd, $MySqlDatabaseName);
    if (mysqli_connect_errno($conn))
    {
        echo json_encode(array("status"=>"500", "msg" => "连接 MySQL 失败: " . mysqli_connect_error()));
    }
    mysqli_query($conn, "set character set 'utf8'");//读库
    mysqli_query($conn, "set names 'utf8'");//写库
    $res = mysqli_query($conn,"SELECT * FROM files WHERE possessor = '$user_name'");
    $files = array();
    for($i = 0;$i<mysqli_num_rows($res);$i++){
        $r = mysqli_fetch_array($res);
        $files[$i] = array("file_name" => $r['file_name'], "possessor" => $r['possessor'],"file_title"=> $r['file_title'],"file_type" => $r['file_type'],"file_time" => $r['file_time'],"file_pwd" => $r['file_pwd']);
    }
    echo json_encode(array("status"=>200,"data" => $files));
    mysqli_close($conn);
}else{
    echo($status_json['status'] . "_" . $status_json['msg'] . "_" . $status_json['time']);
}
